const request = require('../util/request')

exports.getRepoTreeList = async function(username, repo, branch, path) {
    const data = await request.get('/repo/tree', {
        params: {
            repo,
            branch,
            username,
            path, // path 需要传递 pancei/apple/banana 这种类型
        }
    })
    return data
}

exports.getRepoBlobHighLisgt = async function(username, repo, branch, path) {
    const data = await request.get('/repo/blob', {
        params: {
            repo,
            branch,
            username,
            path,
        }
    })
    return data
}

exports.createRepo = async function(username, name, type, description) {
    const res = await request.request({
        url: '/user/repo',
        method: 'POST',
        data: JSON.stringify({
            username, name, type, description,
        }),
        headers: {
            'Content-Type': 'application/json',
        }
    })
    return res
}